//我的资源

var isover=0;
var username;//用户中文名
var currentIndex=1;//页码
$().ready(function(){
    $.ajax({
        type: "post",
        datatype: "json",
        url: userurl,
        data:{"userId":id},
        success:function(data){
            username=data.Data.nick;
            aj();
        }
    });
});
$(".mweb_modal_back_button").click(function(){
    if(document.referrer){history.go(-1);}
    else{location.href="setpage.html";}
});
var ajaxrunning="yes";//初始状态不可以滚动
function aj(){
    if(isover===0){
        ajaxrunning="yes";
        $.ajax({
            type:"get",
            datatype: "json",
            url: getMyResListUrl+"?userId="+id+"&pageSize=15&currentIndex="+currentIndex,
            success:function(d){
                console.log(d);
                if(d.Message==="没有数据"){
                    isover=1;//没有数据了
                    $("#waiting").css("display","none");
                    $("#nonews").css("display","block");
                }else{
                    if(d.Data&&d.Data.length>0){
                        if(d.Data.length<15){
                            $("#waiting").css("display","none");
                            $("#nonews").css("display","block");
                        }
                        var num=0;
                        for(var i=0;i<d.Data.length;i++){
                            num++;
                            if(num===d.Data.length){
                                ajaxrunning="no";
                            }
                            if(d.Data[i].title){
                                var jname1="";
                                var reg2=/[\u4E00-\u9FA5]*/;
                                var unick1="";
                                unick1=d.Data[i].userNick;
                                var count=0;
                                if(d.Data[i].browseCount){count=d.Data[i].browseCount;}
                                //判断是否有点赞者
                                var userimg="";//评星
                                userimg="<div class='starimg'><i style='width:"+parseFloat(d.Data[i].star)*20+"%;'></i></div>";
                                //高额
                                var isheilogo="";
                                var expire="";
                                if(d.Data[i].isHigh===1||d.Data[i].isHigh===2){
                                    isheilogo="<div class='isheighlogo'></div>";
                                    expire="<span class='daynum'>有效期"+d.Data[i].expireDay+"天</span><span>预期总收入"+parseFloat(d.Data[i].totalamount)/100+"元</span>";
                                }
                                //时间
                                var tim=d.Data[i].cTime.match(/([0-9\-]+)/)[0];
                                if(d.Data[i].cTime){
                                    tim=getDateDiff(getDateTimeStamp(d.Data[i].cTime));
                                };
                                if(!tim){tim="刚刚"}
                                //匿名
                                var nimingimg="";
                                if(d.Data[i].isHideName===1){
                                    nimingimg="<img class='rt' src='img/niming.png'>"
                                }
                                //金额
                                var money="";//有没有钱
                                var tit=codetoface(d.Data[i].title);
                                if(d.Data[i].score>0){
                                    var score= parseFloat(d.Data[i].score)/100;
                                    money="<span class='havemy'><img src='img/money04.png'>"+score+"</span>";
                                }
                                //是不是转换
                                var isconvert="";
                                if(d.Data[i].isconvert&&d.Data[i].isconvert===1){
                                    isconvert="&nbsp;&nbsp;(悬赏转经验)"
                                }
                                $("#questionlist").append("<div class='pagedlist_item shareexperience'><div class='feed_item feed_type_question'><div class='EventHeader'><span class='senduser'>"+unick1+"</span><span class='job'>·</span>"+tim+money+isheilogo+nimingimg+isconvert+"</div><h2><a class='question_link' href='shareexppage.html?eid="+d.Data[i].id+"#fromuser="+id+"'>"+tit+"</a></h2><div class='upviter' style='display:none;'>"+userimg+"</div>"+expire+"<div class='ActionBar Question'> <div class='action_bar_inner'><div class='action_item'> <a class='ReadMoreActionItem'>浏览 "+count+"</a> </div> </div></div></div></div>");
                            }
                        }
                    }
                    else{
                        $("#waiting").css("display","none");
                        $("#nonews").css("display","block");
                    }
                }

            }
        })
    }
}
$(window).scroll(function(){
    var mainheight=$(".home_feed").height();
    var windowheight=$(window).height();
    var chajuli=$(".home_feed").offset().top - $(window).scrollTop();
    var cz=windowheight-mainheight+50;
    if(chajuli<cz&&ajaxrunning==="no"){
        console.log(ajaxrunning);
        currentIndex++;
        aj();
    }
});